package edu.hqu.demo.controller;

import edu.hqu.demo.pojo.Student;
import edu.hqu.demo.service.StudentSerivice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Arrays;
import java.util.Map;

@Controller
public class LoginContoller {
    @Autowired
    private StudentSerivice studentSerivice;

    @RequestMapping("/vertify")
    public String login(@RequestParam("Sno") String Sno, @RequestParam("password") String password, Model model, HttpSession session, HttpServletRequest request) {
        if(password.equals(studentSerivice.getStudentPassword(Sno))){
            session.setAttribute("loginuser", Sno);
            Student student = studentSerivice.getStudentInformation(Sno);
            model.addAttribute("msg",student);
            return "personal";
        }
        else{
            return "login";
        }
    }
}

